package com.qhhc.hospital.controller;

import com.qhhc.hospital.entity.Arrange;
import com.qhhc.hospital.service.IArrangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArrangeController {
    @Autowired
    IArrangeService arrangeService;

    @RequestMapping("/insertArrange")
    public String insertArrange(@RequestBody Arrange arrange){
        arrangeService.insert(arrange);
        return "success";
    }

    @RequestMapping("/getAllArranges")
    public List<Arrange> getAllArranges(){
        List<Arrange> arranges = arrangeService.selectAll();
        return arranges;
    }

    @RequestMapping("/getArrange/{arId}")
    public Arrange getArrangeById(@PathVariable("arId") String arId){
        return arrangeService.selectById(arId);
    }
    
    @RequestMapping("/getArrangeByDoctor/{dId}")
    public List<Arrange> getArrangeByDoctorId(@PathVariable("dId") Integer dId){
        return arrangeService.selectByDoctorId(dId);
    }

    @RequestMapping("/updateArrange")
    public String updateArrange(@RequestBody Arrange arrange){
        arrangeService.update(arrange);
        return "success";
    }

    @RequestMapping("/deleteArrange/{arId}")
    public String deleteArrange(@PathVariable("arId") String arId){
        arrangeService.delete(arId);
        return "success";
    }
}